<?php

namespace app\manage\controller;

use app\BaseController;
use yiqiniu\extend\library\GlobalParam;

class BaseApi extends BaseController
{
    /**
     * @var int 当前操作人
     */
    protected int $opUser = 0;

    protected int $isSuper = 0;

    protected array $userInfo = [];

    // 初始化
    protected function initialize()
    {
        if (isset($this->request->request_authInfo)) {
            $this->opUser = $this->request->request_authInfo['id'] ?? 0;
            $this->isSuper = $this->request->request_authInfo['is_super'] ?? 0;
            $this->userInfo = $this->request->request_authInfo;
            GlobalParam::getInstance()->put('op_user', $this->opUser);
            GlobalParam::getInstance()->put('group_id', $this->userInfo['group_id']);
            GlobalParam::getInstance()->put('op_name', ($this->userInfo['nickname'] ?? '') . '|' . ($this->userInfo['mobile'] ?? ''));
        }
    }
}